# Maintainer: Alexander F. Rødseth <xyproto@archlinux.org>
# Contributor: Mosra <mosra@centrum.cz>

# An up-to-date version of this PKGBUILD is maintained at
# https://github.com/mosra/magnum-plugins/blob/master/package/archlinux/magnum-plugins/PKGBUILD

pkgname=magnum-plugins
pkgver=2020.06
_basis_pkgver=2f43afcc97d0a5dafdb73b4e24e123cf9687a418
_meshoptimizer_pkgver=0.14
pkgrel=1
pkgdesc='Plugins for the Magnum C++11/C++14 graphics engine'
arch=(x86_64)
url='https://magnum.graphics'
license=(MIT)
depends=(assimp devil faad2 freetype2 libjpeg libpng libwebp "magnum>=$pkgver" openexr spirv-tools glslang zstd)
makedepends=(cmake git ninja)
source=("git+https://github.com/mosra/magnum-plugins#tag=v$pkgver"
        # A commit that's before the UASTC support (which is not implemented
        # yet, because latest versions crash even on trivial tests)
        "https://github.com/BinomialLLC/basis_universal/archive/${_basis_pkgver}.tar.gz"
        "https://github.com/zeux/meshoptimizer/archive/v${_meshoptimizer_pkgver}.tar.gz"
        )
sha256sums=('SKIP'
            'f983ab5bfc5c32474914a87d9ca572c7fb970bf96f7bc68385c08772f633639f'
            '5a6e429ecf72325131b439a46297a690f0cab833c7563efdadab26c0a6cf8490')

build() {
  mkdir -p build
  cd build

  # Bundle Basis Universal and meshoptimizer
  ln -sf $srcdir/basis_universal-${_basis_pkgver}/ "$srcdir/${pkgname%-git}/src/external/basis-universal"
  ln -sf $srcdir/meshoptimizer-${_meshoptimizer_pkgver}/ "$srcdir/${pkgname%-git}/src/external/meshoptimizer"

  cmake "$srcdir/magnum-plugins" \
    -DCMAKE_BUILD_TYPE=Release \
    -DCMAKE_INSTALL_PREFIX=/usr \
    -DMAGNUM_WITH_ASSIMPIMPORTER=ON \
    -DMAGNUM_WITH_ASTCIMPORTER=ON \
    -DMAGNUM_WITH_BASISIMAGECONVERTER=ON \
    -DMAGNUM_WITH_BASISIMPORTER=ON \
    -DMAGNUM_WITH_BCDECIMAGECONVERTER=ON \
    -DMAGNUM_WITH_CGLTFIMPORTER=ON \
    -DMAGNUM_WITH_DDSIMPORTER=ON \
    -DMAGNUM_WITH_DEVILIMAGEIMPORTER=ON \
    -DMAGNUM_WITH_DRFLACAUDIOIMPORTER=ON \
    -DMAGNUM_WITH_DRMP3AUDIOIMPORTER=ON \
    -DMAGNUM_WITH_DRWAVAUDIOIMPORTER=ON \
    -DMAGNUM_WITH_ETCDECIMAGECONVERTER=ON \
    -DMAGNUM_WITH_FAAD2AUDIOIMPORTER=ON \
    -DMAGNUM_WITH_FREETYPEFONT=ON \
    -DMAGNUM_WITH_GLSLANGSHADERCONVERTER=ON \
    -DMAGNUM_WITH_GLTFIMPORTER=ON \
    -DMAGNUM_WITH_GLTFSCENECONVERTER=ON \
    -DMAGNUM_WITH_ICOIMPORTER=ON \
    -DMAGNUM_WITH_JPEGIMAGECONVERTER=ON \
    -DMAGNUM_WITH_JPEGIMPORTER=ON \
    -DMAGNUM_WITH_KTXIMAGECONVERTER=ON \
    -DMAGNUM_WITH_KTXIMPORTER=ON \
    -DMAGNUM_WITH_LUNASVGIMPORTER=OFF \
    -DMAGNUM_WITH_MESHOPTIMIZERSCENECONVERTER=ON \
    -DMAGNUM_WITH_MINIEXRIMAGECONVERTER=ON \
    -DMAGNUM_WITH_OPENEXRIMAGECONVERTER=ON \
    -DMAGNUM_WITH_OPENEXRIMPORTER=ON \
    -DMAGNUM_WITH_OPENGEXIMPORTER=ON \
    -DMAGNUM_WITH_PNGIMAGECONVERTER=ON \
    -DMAGNUM_WITH_PNGIMPORTER=ON \
    -DMAGNUM_WITH_PLUTOSVGIMPORTER=OFF \
    -DMAGNUM_WITH_PRIMITIVEIMPORTER=ON \
    -DMAGNUM_WITH_RESVGIMPORTER=OFF \
    -DMAGNUM_WITH_SPIRVTOOLSSHADERCONVERTER=ON \
    -DMAGNUM_WITH_SPNGIMPORTER=OFF \
    -DMAGNUM_WITH_STANFORDIMPORTER=ON \
    -DMAGNUM_WITH_STANFORDSCENECONVERTER=ON \
    -DMAGNUM_WITH_STBDXTIMAGECONVERTER=ON \
    -DMAGNUM_WITH_STBIMAGECONVERTER=ON \
    -DMAGNUM_WITH_STBIMAGEIMPORTER=ON \
    -DMAGNUM_WITH_STBRESIZEIMAGECONVERTER=ON \
    -DMAGNUM_WITH_STBTRUETYPEFONT=ON \
    -DMAGNUM_WITH_STBVORBISAUDIOIMPORTER=ON \
    -DMAGNUM_WITH_STLIMPORTER=ON \
    -DMAGNUM_WITH_TINYGLTFIMPORTER=ON \
    -DMAGNUM_WITH_UFBXIMPORTER=ON \
    -DMAGNUM_WITH_WEBPIMAGECONVERTER=ON \
    -DMAGNUM_WITH_WEBPIMPORTER=ON \
    -GNinja
  ninja
}

package() {
  DESTDIR="$pkgdir" ninja -C build install
  install -Dm644 $pkgname/COPYING \
    "$pkgdir/usr/share/licenses/$pkgname/COPYING"
}

# getver: github.com/mosra/magnum-plugins/releases/latest
# vim: ts=2 sw=2 et:
